import { Window } from "../../../component/window/Window";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { LoaderManager } from "../../../../com/gengine/resource/LoaderManager";
import { ObjCreate } from "../common/ObjCreate";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { Language } from "../../../../extend/language/Language";
import { ImgTxt } from "../task/imgtxt/ImgTxt";
import { Cache } from "../../cache/Cache";
import { ESex } from "../../../../Message/Public/ESex";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
import { AIManager } from "../../scene/ai/AIManager";
import { ENpcEffect } from "../../../../Message/Public/ENpcEffect";
import { AIType } from "../../scene/ai/AIType";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { SWedding } from "../../../../Message/Public/SWedding";
import { SPublicMiniPlayer } from "../../../../Message/Public/SPublicMiniPlayer";
import { AvatarInfo } from "../../resource/info/AvatarInfo";
import { AvatarType } from "../../resource/info/AvatarType";
import { ImageInfo } from "../../../../com/gengine/resource/info/ImageInfo";
//class MarryRegister
    
    export  class MarryRegister extends Window
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(470, 229);
            return;
        }

        protected /* override */ createChildren(): void
        {
            var loc3=null;
            var loc6=null;
            super.createChildren();
            var loc1=new GTextFormat(FontUtil.songtiName, 14, 16777215);
            loc1.leading = 9;
            var loc2=new GTextFormat(FontUtil.songtiName, 12, 11661311);
            loc2.leading = 3;
            this._bg = new Object /* flash.display.Bitmap */();
            this.addChild(this._bg);
            LoaderManager.instance.load("MarryBg.png", this.onLoadComplete);
            this._tfCongra = ObjCreate.createTextField("", 88, 147, 330, 20, this, GlobalStyle.textFormat6);
            this._tfBless = ObjCreate.createTextField("", 118, 173, 330, 70, this, loc1);
            this._tfBless.multiline = true;
            this._tfBless.wordWrap = true;
            this._tfBless.htmlText = Language.getString(43591);
            this._tfTips = ObjCreate.createTextField("", 88, 248, 280, 40, this, loc2);
            this._tfTips.htmlText = Language.getString(43592);
            this._tfTips.multiline = true;
            this._tfTips.wordWrap = true;
            this._tfTips.addEventListener(flash.events.TextEvent.LINK, this.onLink);
            loc3 = new ImgTxt();
            this.addChild(loc3);
            loc3.x = 0;
            loc3.y = -3;
            var loc4=loc3.bulidPic("fly", 0, this._tfTips, "FlyBoot_upSkin", false, 1);
            loc4 = 0;
            var loc5=loc3.numChildren;
            while (loc4 < loc5) 
            {
                (loc6 = loc3.getChildAt(loc4) as Object /* flash.display.Sprite */).addEventListener(flash.events.MouseEvent.CLICK, this.onClick);
                ++loc4;
            }
            this._bmpMan = new Object /* flash.display.Bitmap */();
            this._bmpMan.x = 123;
            this._bmpMan.y = 67;
            this.addChild(this._bmpMan);
            this._bmpWomen = new Object /* flash.display.Bitmap */();
            this._bmpWomen.x = 295;
            this._bmpWomen.y = 67;
            this.addChild(this._bmpWomen);
            if (Cache.instance.role.entityInfo.sex == ESex._ESexMan) 
            {
                this._btnBooking = ObjCreate.createGLoadedButton("MarryBtn", 50, 290, 180, 39, this);
                this._btnBooking.label = Language.getString(43593);
                this.setMarryBtnStyle(this._btnBooking);
                this._btnLater = ObjCreate.createGLoadedButton("MarryBtn", 240, 290, 180, 39, this);
                this._btnLater.label = Language.getString(43594);
                this.setMarryBtnStyle(this._btnLater);
                this._btnBooking.addEventListener(flash.events.MouseEvent.CLICK, this.onClickBooking);
                this._btnLater.addEventListener(flash.events.MouseEvent.CLICK, this.onClickLater);
            }
            return;
        }

        /* internal  */setMarryBtnStyle(arg1: GLoadedButton): void
        {
            var loc1=new GTextFormat(FontUtil.songtiName, 12, 11661308);
            var loc2=new GTextFormat(FontUtil.songtiName, 12, 15859633);
            arg1.setStyle("textFormat", loc1);
            arg1.setStyle("disabledTextFormat", loc2);
            return;
        }

        /* internal  */onClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            AIManager.onAIControl(Cache.instance.scene.getNpcByEffect(ENpcEffect._ENpcEffectMarryRegister), AIType.AI_Convey);
            return;
        }

        /* internal  */onLink(arg1: Object /* flash.events.TextEvent */): void
        {
            AIManager.onAutoPathAIControl(Cache.instance.scene.getNpcByEffect(ENpcEffect._ENpcEffectMarryRegister));
            return;
        }

        /* internal  */onClickBooking(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.MarryShowBookingWindow));
            this.hide();
            return;
        }

        /* internal  */onClickLater(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.hide();
            return;
        }

        protected /* override */ updateBtnSize(): void
        {
            if (_closeBtn) 
            {
                _closeBtn.x = 385;
                _closeBtn.y = 46;
            }
            return;
        }

        public updateMarryMsg(arg1: SWedding): void
        {
            this.updateHeadImage(arg1.man, arg1.woman);
            this._tfCongra.text = Language.getStringByParam(43597, arg1.marryCount.toString());
            return;
        }

        /* internal  */updateHeadImage(arg1: SPublicMiniPlayer, arg2: SPublicMiniPlayer): void
        {
            var man: SPublicMiniPlayer;
            var woman: SPublicMiniPlayer;

            var loc1;
            man = arg1;
            woman = arg2;
            AvatarInfo.getAvatar(man.camp, man.sex, AvatarType.SMALL, (arg1: ImageInfo): void
            {
                _bmpMan.bitmapData = arg1.bitmapData;
                return;
            }, man.avatarId)
            AvatarInfo.getAvatar(woman.camp, woman.sex, AvatarType.SMALL, (arg1: ImageInfo): void
            {
                _bmpWomen.bitmapData = arg1.bitmapData;
                return;
            }, woman.avatarId)
            return;
        }

        /* internal  */onLoadComplete(arg1): void
        {
            this._bg.bitmapData = arg1.bitmapData as Object /* flash.display.BitmapData */;
            return;
        }

        /* internal */ /* var */_bg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tfCongra: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfBless: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfTips: Object /* flash.text.TextField */;

        /* internal */ /* var */_btnBooking: GLoadedButton;

        /* internal */ /* var */_btnLater: GLoadedButton;

        /* internal */ /* var */_bmpMan: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_bmpWomen: Object /* flash.display.Bitmap */;
    }
